import axios from 'axios';

const API_URL = 'http://localhost:8000/api/users/';

const token = localStorage.getItem('access');

// 创建一个带有默认配置的 axios 实例
const apiClient = axios.create({
  baseURL: API_URL,
  headers: {
    'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json',
  },
});

export const getUsers = () => apiClient.get('/');
export const createUser = (user) => apiClient.post('/', user);
export const updateUser = (id, user) => apiClient.put(`${id}/`, user);
export const deleteUser = (id) => apiClient.delete(`${id}/`);